/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mapping;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Andres
 */
@Entity
@Table(name = "ticket")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Ticket.findAll", query = "SELECT t FROM Ticket t"),
    @NamedQuery(name = "Ticket.findByIdTicket", query = "SELECT t FROM Ticket t WHERE t.idTicket = :idTicket"),
    @NamedQuery(name = "Ticket.findByDescripcion", query = "SELECT t FROM Ticket t WHERE t.descripcion = :descripcion"),
    @NamedQuery(name = "Ticket.findByPrioridad", query = "SELECT t FROM Ticket t WHERE t.prioridad = :prioridad"),
    @NamedQuery(name = "Ticket.findByEstado", query = "SELECT t FROM Ticket t WHERE t.estado = :estado"),
    @NamedQuery(name = "Ticket.findByFechaInicio", query = "SELECT t FROM Ticket t WHERE t.fechaInicio = :fechaInicio"),
    @NamedQuery(name = "Ticket.findByFechaFin", query = "SELECT t FROM Ticket t WHERE t.fechaFin = :fechaFin"),
    @NamedQuery(name = "Ticket.findByTipoProblema", query = "SELECT t FROM Ticket t WHERE t.tipoProblema = :tipoProblema")})
public class Ticket implements Serializable {
    @JoinColumn(name = "idSolucion", referencedColumnName = "id")
    @ManyToOne
    private Solucion idSolucion;
    @OneToMany(mappedBy = "idTicket")
    private Collection<ReporteCambio> reporteCambioCollection;
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "idTicket")
    private String idTicket;
    @Basic(optional = false)
    @Column(name = "descripcion")
    private String descripcion;
    @Basic(optional = false)
    @Column(name = "prioridad")
    private String prioridad;
    @Basic(optional = false)
    @Column(name = "estado")
    private String estado;
    @Basic(optional = false)
    @Column(name = "FechaInicio")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fechaInicio;
    @Basic(optional = false)
    @Column(name = "FechaFin")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fechaFin;
    @Basic(optional = false)
    @Column(name = "tipoProblema")
    private String tipoProblema;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "ticket")
    private Collection<CambioComp> cambioCompCollection;
    @JoinColumn(name = "EmpResolvio", referencedColumnName = "idEmpleado")
    @ManyToOne
    private Empleado empResolvio;
    @JoinColumn(name = "EmpSolicito", referencedColumnName = "idEmpleado")
    @ManyToOne
    private Empleado empSolicito;
    @JoinColumn(name = "empAtendio", referencedColumnName = "idEmpleado")
    @ManyToOne
    private Empleado empAtendio;
    @JoinColumn(name = "idDispositivo", referencedColumnName = "idDisp")
    @ManyToOne
    private Dispositivo idDispositivo;

    public Ticket() {
    }

    public Ticket(String idTicket) {
        this.idTicket = idTicket;
    }

    public Ticket(String idTicket, String descripcion, String prioridad, String estado, Date fechaInicio, Date fechaFin, String tipoProblema) {
        this.idTicket = idTicket;
        this.descripcion = descripcion;
        this.prioridad = prioridad;
        this.estado = estado;
        this.fechaInicio = fechaInicio;
        this.fechaFin = fechaFin;
        this.tipoProblema = tipoProblema;
    }

    public String getIdTicket() {
        return idTicket;
    }

    public void setIdTicket(String idTicket) {
        this.idTicket = idTicket;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public String getPrioridad() {
        return prioridad;
    }

    public void setPrioridad(String prioridad) {
        this.prioridad = prioridad;
    }

    public String getEstado() {
        return estado;
    }

    public void setEstado(String estado) {
        this.estado = estado;
    }

    public Date getFechaInicio() {
        return fechaInicio;
    }

    public void setFechaInicio(Date fechaInicio) {
        this.fechaInicio = fechaInicio;
    }

    public Date getFechaFin() {
        return fechaFin;
    }

    public void setFechaFin(Date fechaFin) {
        this.fechaFin = fechaFin;
    }

    public String getTipoProblema() {
        return tipoProblema;
    }

    public void setTipoProblema(String tipoProblema) {
        this.tipoProblema = tipoProblema;
    }

    @XmlTransient
    public Collection<CambioComp> getCambioCompCollection() {
        return cambioCompCollection;
    }

    public void setCambioCompCollection(Collection<CambioComp> cambioCompCollection) {
        this.cambioCompCollection = cambioCompCollection;
    }

    public Empleado getEmpResolvio() {
        return empResolvio;
    }

    public void setEmpResolvio(Empleado empResolvio) {
        this.empResolvio = empResolvio;
    }

    public Empleado getEmpSolicito() {
        return empSolicito;
    }

    public void setEmpSolicito(Empleado empSolicito) {
        this.empSolicito = empSolicito;
    }

    public Empleado getEmpAtendio() {
        return empAtendio;
    }

    public void setEmpAtendio(Empleado empAtendio) {
        this.empAtendio = empAtendio;
    }

    public Dispositivo getIdDispositivo() {
        return idDispositivo;
    }

    public void setIdDispositivo(Dispositivo idDispositivo) {
        this.idDispositivo = idDispositivo;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idTicket != null ? idTicket.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Ticket)) {
            return false;
        }
        Ticket other = (Ticket) object;
        if ((this.idTicket == null && other.idTicket != null) || (this.idTicket != null && !this.idTicket.equals(other.idTicket))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.mapping.Ticket[ idTicket=" + idTicket + " ]";
    }

    @XmlTransient
    public Collection<ReporteCambio> getReporteCambioCollection() {
        return reporteCambioCollection;
    }

    public void setReporteCambioCollection(Collection<ReporteCambio> reporteCambioCollection) {
        this.reporteCambioCollection = reporteCambioCollection;
    }

    public Solucion getIdSolucion() {
        return idSolucion;
    }

    public void setIdSolucion(Solucion idSolucion) {
        this.idSolucion = idSolucion;
    }
    
}
